﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Services;
using Entities;

namespace WebUI.Controllers
{
    public partial class SummaryController : Controller
    {
        #region Member Variables

        readonly ISummaryService _summaryService;

        #endregion

        #region Constructor

        public SummaryController(ISummaryService summaryService)
        {
            this._summaryService = summaryService;
        }

        #endregion

        #region Actions

        [OutputCache(Duration = 3600, VaryByParam = "userAccount")]
        public virtual PartialViewResult UserSummary(string userAccount)
        {
            UserSummary userSummary = _summaryService.GetUserSummary(userAccount);
            return PartialView(userSummary);
        }

        [OutputCache(Duration = 3600, VaryByParam = "serverName")]
        public virtual PartialViewResult MachineTopAccessors(string serverName)
        {
            IEnumerable<string> machineTopAccessors = _summaryService.GetMachineTopAccessors(serverName);
            return PartialView(machineTopAccessors);
        }

        [OutputCache(Duration = 3600, VaryByParam = "path")]
        public virtual PartialViewResult DirectoryOwner(string path)
        {
            string owner = _summaryService.GetDirectoryOwner(path);
            return PartialView((object)owner);
        }

        [OutputCache(Duration = 3600, VaryByParam = "fileName")]
        public virtual PartialViewResult FileSummary(string fileName)
        {
            FileSummary fileSummary = _summaryService.GetFileSummary(fileName);
            return PartialView(fileSummary);
        }

        #endregion
    }
}